from Vine import *
def BuildKeyRange(l,r):
	return (ord(l),ord(r) + 1)
class StateFilter:
	def __init__(self, **kwarg):
		self.forbidden = IMStateNone
		self.allowed   = IMStateAll
		self.expected  = IMStateNone
		if 'forbidden' in kwarg : self.forbidden = kwarg['forbidden']
		if 'allowed' in kwarg : self.forbidden = kwarg['allowed']
		if 'expected' in kwarg : self.expected = kwarg['excepted']
	def AllowModifier(self, modifier):
		self.forbidden &= ~modifier
		self.expected  &= ~modifier
		self.allowed   |=  modifier
	def DisallowModifier(self, modifier):
		self.forbidden |=  modifier
		self.expected  &= ~modifier
		self.allowed   &= ~modifier
	def ExpectModifier(self, modifier):
		self.forbidden &= ~modifier
		self.expected  |=  modifier
		self.allowed   &= ~modifier
class IMEBase:
	def PreeditTextChanged(self,text): pass
	def Enabled(self): pass
	def Disabled(self): pass
	def SetTrayIcon(self,path):
		return SetTrayIcon(self,path)
	def Commit(self,text):
		return Commit(self,text)
	def UpdateCandidates(self, cand):
		return UpdateCandidates(self,cand)
	def UpdatePrecommitText(self, text):
		return UpdatePrecommitText(self,text)
	def RegisterForwardFilter(self, sym_range, state_filter, release, callback):
		return RegisterForwardFilter(self, sym_range[0], sym_range[1],
						  state_filter.forbidden, state_filter.expected,
						  release, callback)
	def SwitchForwardFilter(self, filter_id, value):
		return SwitchForwardFilter(self, filter_id, value)
	def ResetForwardFilter(self):
		return ResetForwardFilter(self)
